{template /common/header}
<style type="text/css">
.app_login > input.Validform_error{ border:1px solid red;}
        	.errmsg{ color:red; text-align:center; line-height:24px; padding-top:5px;}
        </style>
<div class="divColor">
<?php
if($step=="" or $step==0){
?>
<ul class="app_register">
  <li class="purpleColor">1.输入手机号</li>
  <li>2.输入验证码</li>
  <li>3.输入账户密码</li>
</ul>
<form class="registerform" action="{U('User/Public/mobilereg',array('step'=>1))}" method="post">
  <div class="zhucefor errmsg" id="win"> </div>
  <div class="app_login">
    <input type="text" id="mobile_phone" ajaxurl="{U('User/Public/ajaxCheckKey')}" datatype="m" maxlength="11" errormsg="手机号错误！" name="mobile_phone" nullmsg='请填写手机号码' placeholder="请输入手机号码" />
    <p class="p3"></p>
  </div>
  <div class="app_loginSub">
    <input type="submit" value="下一步" />
  </div>
  <div class="app_loginSub app_regSub">
    <input type="button" onclick="window.location.href='{U('Public/login')}'" value="我已有账号，马上登录？" />
  </div>
</form>
<script type="text/javascript">
			$(function(){
				$(".registerform").Validform({
					tiptype:function(msg,o,cssctl){
						if(o.type==1){
							o.obj.addClass("Validform_success")
						}
						if(o.type==3){
							o.obj.removeClass("Validform_success").addClass("Validform_error")
							$(".errmsg").text(msg).show();
							return false;
						}
					},
				});
			});
			
		</script>
<?php
}elseif($step==1){
?>
<ul class="app_register">
  <li>输入手机号</li>
  <li class="active">输入验证码</li>
  <li>输入账户密码</li>
</ul>
<form class="registerform" action="{U('User/Public/mobilereg',array('step'=>2))}" method="post">
  <div class="app_login">
    <input type="text" value="{$mobile_phone}" name="mobile_phone"  readonly="readonly" style="background:#CCC; cursor:no-drop"/>
    <p class="p3"></p>
  </div>
  <div class="app_login">
    <input type="text" name="mobi_code" datatype="n" maxlength="6" placeholder="请输入手机验证码" nullmsg='请填写验证码' />
    <p class="p4"></p>
  </div>
  <div class="app_loginSub">
    <input type="submit" value="下一步" />
  </div>
</form>
<div class="app_loginYZM">
  <p></p>
</div>
<div class="app_loginSub app_regSub2">
  <input type="button" class="send_code" value="免费获取验证码" />
</div>
<script type="text/javascript">
$(function(){
	$(".registerform").Validform({
		tiptype:function(msg,o,cssctl){
			if(o.type==1){
				o.obj.addClass("Validform_success")
			}
			if(o.type==3){
				o.obj.removeClass("Validform_success").addClass("Validform_error")
				$(".errmsg").text(msg).show();
				return false;
			}
		},
	});
});
</script> 
<script type="text/javascript">				
$(function(){
	$(".send_code").click();
    $(".send_code").click(function(){
        var text=$(this).val();
        var type=$(this).attr("type");
        if(text!="免费获取验证码"){
            return false;
        }
		$.ajax({url: "{U('User/Public/send_code')}&token={$_SESSION[send_code_time]}&mobile={$mobile_phone}",timeout: 5000,cache: false,type: "get",async : false,dataType: "json",success: function (d) {
			if(d.status==1){
				 downtime(120);	
			}
			alert(d.info);
		}});
    })
})
/**
* 验证码倒计时
* time 倒计时时间：秒
**/
function downtime(time){
//循环调用
if(time == '0'){
	$('.send_code').val('免费获取验证码');
	$('.app_loginYZM').html('<p>验证码已发送{$mobile_phone} ,可以重新发送</p>');
}else{
	time --;
	$('.send_code').val('重新发送（'+time+'）');
	$('.app_loginYZM').html('<p>验证码已发送{$mobile_phone} ,'+time+'秒后可以重新发送</p>');
	setTimeout(function() {
		downtime(time);
	},1000);} 
}
</script>
<?php
}elseif($step==2){
?>
<ul class="app_register">
  <li>1.手机验证</li>
  <li class="purpleColor">2.输入账号密码</li>
  <li>3.注册成功</li>
</ul>
<form class="registerform" action="{U('User/Public/mobilereg',array('step'=>3))}" method="post">
  <div class="zhucefor errmsg" id="win"> </div>
  <div class="app_login">
    <input type="text" name="username" ajaxurl="{U('User/Public/ajaxCheckKey')}" datatype="*2-18" errormsg="用户名不低于两位，使用中文、数字、字母皆可！" nullmsg='请填写用户名' placeholder="用户名不低于两位，使用中文、数字、字母皆可" />
    <p class="p1"></p>
  </div>
  <div class="app_login">
    <input type="text" value="{$mobile_phone}" name="mobile_phone"  readonly="readonly" style="background:#CCC; cursor:no-drop"/>
    <p class="p3"></p>
  </div>
  <div class="app_login">
    <input type="password"  datatype="password" errormsg="登录密码范围在6~15位之间！" name="password" id="password" nullmsg='请填写密码，密码范围在6~15位之间' placeholder="请输入登录密码"/>
    <p class="p2"></p>
  </div>
  <div class="app_login">
    <input  type="password" name="userpassword2" datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致！" nullmsg='请确认登录密码' placeholder="请再次确认密码"/>
    <p class="p2"></p>
  </div>
  <label class="app_regAgreement" for="regAgreement">
    <input checked="checked" type="checkbox" name="checkbox" id="checkbox"  sucmsg=" " datatype="need1" nullmsg="请接受服务协议" >
    我已阅读并同意金商道<span>《<a href="/index.php?m=help&c=help&a=detail&id=31">用户协议</a>》</span></label>
  <div class="app_loginSub">
    <input type="submit" value="下一步" />
  </div>
</form>
<div class="app_loginSub app_regSub">
  <input type="button" value="我已有账号，马上登录？" />
</div>
<script type="text/javascript">
		$(function(){
		$(".registerform").Validform({
			tiptype:function(msg,o,cssctl){
				if(o.type==1){
					o.obj.addClass("Validform_success")
				}
				if(o.type==3){
					o.obj.removeClass("Validform_success").addClass("Validform_error")
					$(".errmsg").text(msg).show();
					return false;
				}
			},
			ajaxPost:true,
			datatype:{
				"password": function( gets , obj , curform , regxp ){
					 var reg1=/^[^\s]{6,15}$/;
					 if(!reg1.test(gets)){
						return "登录密码范围在6~15位之间";
					 }  
				},
				"need1": function( gets , obj , curform , regxp ){
					var need=1,
						numselected=curform.find("input[name='"+obj.attr("name")+"']:checked").length;
					return  numselected >= need ? true : "请阅读服务协议";
				}
			},
			callback: function(data) {
				if (data.status == 1) {
					alert(data.info);
					window.location.href=data.url;
				}else{
					alert(data.info);
				}
			}
		});
	});
		</script>
<?php
}elseif($step==2){

?>
<?php
}elseif($step==3){

}

?>
{template /common/footer}